﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace ChatService
{
    [ServiceContract]
    public interface IChatService
    {
        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "Channels/all")]
        IEnumerable<ChannelDTO> GetChanellsAll();

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "GetMessagesInChannel/{channelID}")]
        IEnumerable<MessageDTO> GetMessagesInChannel(string channelID);

        [OperationContract]
        [WebInvoke(
            Method = "POST", 
            UriTemplate = "/PostMessage",
            BodyStyle = WebMessageBodyStyle.WrappedRequest,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json
        )]
        void PostMessage(Post post);
    }

    [DataContract]
    public class Post
    {
        [DataMember]
        public string ChannelName { get; set; }

        [DataMember]
        public string Body { get; set; }

        [DataMember]
        public string Date { get; set; }
    }
}
